{include file="common/meta" /}
{include file="common/script" /}
<link href="__CDN__/assets/libs/fastadmin-citypicker/dist/css/city-picker.css" rel="stylesheet" />
<div class="container-fluid margin padding">
	<div class="row">
		<!-- 订单信息 -->
		<div class="col-md-10 col-md-offset-1 col-sm-12">
			<form class="form-horizontal" method="POST" name="myForm" id="myForm" action="">
			    <div class="form-group hide">
			        <label for="country" class="col-sm-2 control-label">{:__('country')}</label>
			        <div class="col-sm-10">
			            <input type="text" class="form-control" id="country" value="中国" readonly name="country" placeholder="{:__('country')}">
			        </div>
			    </div>
			    <div class="form-group">
			        <label for="country" class="col-sm-2 control-label">{:__('province / city / xian')}</label>
			        <div class="col-sm-10">
			        	<div style="position:relative;">
			            	<input type="text" class="form-control" data-responsive="true" data-toggle="city-picker" id="region" name="region" placeholder="{:__('province / Region')}">
			        	</div>
			        </div>
			    </div>
			    <div class="form-group">
			        <label for="city" class="col-sm-2 control-label">{:__('set default')}</label>
			        <div class="col-sm-10 padding-top">
						<!-- radio -->
						<div class="form-group" style="padding-left: 15px;">
							<label>
								<input type="radio" name="status" value="1" class="flat-red" />
								{:__('yes')}
							</label>
							<label>
								<input type="radio" name="status" class="flat-red" value="0" checked />
								{:__('no')}
							</label>
						</div>
			        </div>
			    </div>
			    <div class="form-group">
			        <label for="zip" class="col-sm-2 control-label">{:__('zip code')}</label>
			        <div class="col-sm-10">
			            <input type="text" class="form-control" id="zip" name="zip" placeholder="{:__('zip code')}">
			        </div>
			    </div>
			    <div class="form-group">
			        <label for="mobile" class="col-sm-2 control-label">{:__('mobile')}</label>
			        <div class="col-sm-10">
			            <input type="text" class="form-control" id="mobile" name="mobile" placeholder="{:__('mobile')}">
			        </div>
			    </div>
			    <div class="form-group">
			        <label for="truename" class="col-xs-2 control-label">{:__('consignee')}</label>
			        <div class="col-xs-10">
			            <input type="text" class="form-control" id="truename" name="truename" placeholder="{:__('姓名')}">
			        </div>
			        
			    </div>

			    <div class="form-group">
			        <label for="detailaddress" class="col-sm-2 control-label">{:__('detail address')}</label>
			        <div class="col-sm-10">
			            <textarea name="address" id="address" class="form-control" rows="5"></textarea>
			        </div>
			    </div>
			    <div class="form-group">
					<div class="col-sm-2 col-sm-offset-5 col-xs-12">
				    	<button class="btn btn-info btn-block" id="add" type="button">{:__('add')}</button>
				    </div>
				</div>
			</form>
		</div>
	</div>
</div>
{include file="common/script"}
<!-- Layer -->
<script src="__CDN__/assets/libs/fastadmin-citypicker/dist/js/city-picker.data.min.js"></script>
<script src="__CDN__/assets/libs/fastadmin-citypicker/dist/js/city-picker.min.js"></script>
<script>
	$(document).ready(function() {
		var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		$("#add").on('click', function() {
			var sta = true;
			$("input[type=text]").each(function(index, el) {
				if($(this).val() == '')
				{
					$(this).focus();
					layer.msg("{:__('art empty tip')}");
					sta = false;
					return false;
				}
			});

			if(sta == false) return false;

			var address = $("#address").val();
			if($.trim(address) == '')
			{
				$("#address").focus();
				layer.msg("{:__('art empty tip')}");
				return false;
			}

			var url = "{:addon_url('leescore/address/add')}";
			var data = $("#myForm").serialize();
			$.ajax({
				url: url,
				type: 'POST',
				dataType: 'json',
				data: data,

				success: function(json)
				{
					if(json.status == true)
					{
						//关闭iframe
						parent.location.reload();
					    parent.layer.close(index);
					}else{
						layer.alert(json.msg, {
							icon: 2,
							skin: 'layer-ext-moon' 
						});
					}
				}
			});
			
		});
	});
</script>
